﻿using System;
using System.ComponentModel;
using System.Reflection;
using NHibernate;

namespace AiFrame.InterfaceLib.Data.Access
{ 
    /// <summary>
    /// Represents the central database connection.
    /// </summary>
    public interface IDatabaseConnection: INotifyPropertyChanged
    {
        /// <summary>
        /// Gets the current session. If there is no session, a new session
        /// is built.
        /// </summary>
        /// <returns></returns>
        ISession GetSession();

        /// <summary>
        /// Gets the NHibernate configuration settings.
        /// </summary>
        NHibernate.Cfg.Configuration Configuration { get; }

        /// <summary>
        /// Closes the session.
        /// </summary>
        void CloseSession();

        /// <summary>
        /// Adds a assembly to the database mapping in order
        /// to register it to NHibernate.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        void AddMappingAssembly(Assembly assembly);

        /// <summary>
        /// Adds a class to the database mapping in order
        /// to register it to NHibernate.
        /// The must be a classname.hbm.xml file for this class.
        /// </summary>
        /// <param name="type"></param>
        void AddMappingClass(Type type);

        /// <summary>
        /// Gets or sets the username for the database connection.
        /// </summary>
        string Username { get; set; }

        /// <summary>
        /// Gets or sets the host address for the database connection.
        /// </summary>
        string HostAddress { get; set; }

        /// <summary>
        /// Sets the password for the database connection.
        /// </summary>
        string Password { set; }

        /// <summary>
        /// Gets or sets the database name for the database connection.
        /// </summary>
        string Database { get; set; }

        /// <summary>
        /// Gets the connection state.
        /// </summary>
        bool Connected { get; }
    }
}
